473,418 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Pass an array to javascript

Hi,

How can I pass an array string to javascript?

I have this:

in ASP.NET VB code:

--------------------------------------------------------------------
Dim siteName(100) As String
Dim siteLink(100) As String
Dim i As Integer

siteName(0) = "New JavaScripts"
siteName(1) = "Item 2"
siteName(2) = "Item 3"
siteName(3) = "Item 4"
siteName(4) = "Item 5"
siteName(5) = "Item 6"
siteLink(0) = "link1"
siteLink(1) = "link2"
siteLink(2) = "link3"
siteLink(3) = "link4"
siteLink(4) = "link5"
siteLink(5) = "link6"

Dim sbScript As New System.Text.StringBuilder
sbScript.Append("<script language='javascript'>")
sbScript.Append(Environment.NewLine)
sbScript.Append("createMenu('siteName','siteLink') ;")
sbScript.Append(Environment.NewLine)
sbScript.Append("</script>")
RegisterStartupScript("OpenMenu", sbScript.ToString())
--------------------------------------------------------------------

in HTML code I have this (at javascript, of course):

function createMenu(siteName, siteLink)
{
for (i = 0; i <= siteName.length - 1; i++)
document.write('<a href=' + siteLink[i] + '>' + siteName[i] + '</a><br>');
}

--------------------------------------------------------------------

What's wrong????
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
Nov 19 '05 #1
6 5558
dgk
On Thu, 24 Mar 2005 14:43:29 -0000, "ruca" <ru***@iol.pt> wrote:
Hi,

How can I pass an array string to javascript?

I have this:

in ASP.NET VB code:

--------------------------------------------------------------------
Dim siteName(100) As String
Dim siteLink(100) As String
Dim i As Integer

siteName(0) = "New JavaScripts"
siteName(1) = "Item 2"
siteName(2) = "Item 3"
siteName(3) = "Item 4"
siteName(4) = "Item 5"
siteName(5) = "Item 6"
siteLink(0) = "link1"
siteLink(1) = "link2"
siteLink(2) = "link3"
siteLink(3) = "link4"
siteLink(4) = "link5"
siteLink(5) = "link6"

Dim sbScript As New System.Text.StringBuilder
sbScript.Append("<script language='javascript'>")
sbScript.Append(Environment.NewLine)
sbScript.Append("createMenu('siteName','siteLink') ;")
sbScript.Append(Environment.NewLine)
sbScript.Append("</script>")
RegisterStartupScript("OpenMenu", sbScript.ToString())
--------------------------------------------------------------------

in HTML code I have this (at javascript, of course):

function createMenu(siteName, siteLink)
{
for (i = 0; i <= siteName.length - 1; i++)
document.write('<a href=' + siteLink[i] + '>' + siteName[i] + '</a><br>');
}

--------------------------------------------------------------------

What's wrong????


I'm just learning this stuff but I'll take a shot. The VB code is
executing on the server and the javascript on the browser. You would
need to pass the information back through something they both have in
common. Perhaps the Document object?
Nov 19 '05 #2
Where you have:

sbScript.Append("createMenu('siteName','siteLink') ;")

You could do:

sbScript.Append("createMenu(new
Array('Item1','Item2','Item3'),'siteLink');")
Nov 19 '05 #3
Dont't work like that.
:(

Any more ideas, p l e a s e????
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

"Joseph Byrns" <jo*********@nnoossppaamm-yahoo.com> escreveu na mensagem
news:ek**************@TK2MSFTNGP14.phx.gbl...
Where you have:

sbScript.Append("createMenu('siteName','siteLink') ;")

You could do:

sbScript.Append("createMenu(new
Array('Item1','Item2','Item3'),'siteLink');")

Nov 19 '05 #4
Hello ruca,

Look at Page.RegisterArrayDeclaration...

--
Matt Berther
http://www.mattberther.com
Hi,

How can I pass an array string to javascript?

I have this:

in ASP.NET VB code:

--------------------------------------------------------------------
Dim siteName(100) As String
Dim siteLink(100) As String
Dim i As Integer
siteName(0) = "New JavaScripts"
siteName(1) = "Item 2"
siteName(2) = "Item 3"
siteName(3) = "Item 4"
siteName(4) = "Item 5"
siteName(5) = "Item 6"
siteLink(0) = "link1"
siteLink(1) = "link2"
siteLink(2) = "link3"
siteLink(3) = "link4"
siteLink(4) = "link5"
siteLink(5) = "link6"
Dim sbScript As New System.Text.StringBuilder
sbScript.Append("<script language='javascript'>")
sbScript.Append(Environment.NewLine)
sbScript.Append("createMenu('siteName','siteLink') ;")
sbScript.Append(Environment.NewLine)
sbScript.Append("</script>")
RegisterStartupScript("OpenMenu", sbScript.ToString())
--------------------------------------------------------------------
in HTML code I have this (at javascript, of course):

function createMenu(siteName, siteLink)
{
for (i = 0; i <= siteName.length - 1; i++)
document.write('<a href=' + siteLink[i] + '>' + siteName[i] +
'</a><br>');
}
--------------------------------------------------------------------

What's wrong????


Nov 19 '05 #5
a quick look at the docs would reveal Page.RegisterArrayDeclaration which
has sample code.

-- bruce (sqlwork.com)
"ruca" <ru***@iol.pt> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Dont't work like that.
:(

Any more ideas, p l e a s e????
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

"Joseph Byrns" <jo*********@nnoossppaamm-yahoo.com> escreveu na mensagem
news:ek**************@TK2MSFTNGP14.phx.gbl...
Where you have:

sbScript.Append("createMenu('siteName','siteLink') ;")

You could do:

sbScript.Append("createMenu(new
Array('Item1','Item2','Item3'),'siteLink');")


Nov 19 '05 #6
That's strange, it works fine here. Hmmm.
"ruca" <ru***@iol.pt> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Dont't work like that.
:(

Any more ideas, p l e a s e????
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

"Joseph Byrns" <jo*********@nnoossppaamm-yahoo.com> escreveu na mensagem
news:ek**************@TK2MSFTNGP14.phx.gbl...
Where you have:

sbScript.Append("createMenu('siteName','siteLink') ;")

You could do:

sbScript.Append("createMenu(new
Array('Item1','Item2','Item3'),'siteLink');")


Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Miguel | last post by:
Hello. I have a Javascript function that validates an specific form. As parameters this function receives an array of elements to be checked. Depending on the form in cause, the array could have...
0
by: Matt | last post by:
My problem is to allow ASP to interact with JSP, and I pass JavaScript object in my approach, but I wonder if it will work in network, not just in local machine. For testing purposes, the...
3
by: Nath | last post by:
Please help!? I am new to writing html, javascript, pretty new to MySQL but quite proficient at writing Perl and i'm a quick learner. I am building a database driven website and i am a little...
5
by: Seeker | last post by:
Newbie question here... I have a form with some radio buttons. To verify that at least one of the buttons was chosen I use the following code ("f" is my form object) : var btnChosen; for...
4
by: Sunny | last post by:
Hi, I am at present working on a jsp page which has a single text field. Upon entering a value in the field, i am trigerring an onChangeEvent() which calls a method of javascript. I am also...
2
by: Augusto Cesar | last post by:
Hello people. How can I Pass ASP Array variable to Javascript; I´m to trying this: <script language="JavaScript"> var x = new Array(10);
2
by: André | last post by:
Hi, I have to pass a lot of variables from vb.net to javascript using client callback. the problem is that there are single variables, but also arrays with differents indexes. I have two...
1
by: thomas_okken | last post by:
I'm working on a little C# DLL that will let me capture audio from within Internet Explorer. The idea is that the C# object, once it is recording, will periodically invoke a JavaScript callback,...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
1
by: mchen1117 | last post by:
I try to display a random image alone with text and link, I find this javascript and did some edit as needed, I don't know how I can pass document.write() value to HREF's URL, Please help ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.